using System.ComponentModel.DataAnnotations;
using VotingSystem.Models;

namespace VotingSystem.ViewModels
{
    public class VoteEditViewModel
    {
        public int Id { get; set; }

        [Required(ErrorMessage = "请输入标题")]
        [StringLength(100, ErrorMessage = "标题长度不能超过100个字符")]
        [Display(Name = "标题")]
        public string Title { get; set; } = string.Empty;

        [StringLength(1000, ErrorMessage = "描述长度不能超过1000个字符")]
        [Display(Name = "描述")]
        public string? Description { get; set; }

        [Required(ErrorMessage = "请选择截止时间")]
        [Display(Name = "截止时间")]
        public DateTime EndTime { get; set; }

        [Display(Name = "是否公开")]
        public bool IsPublic { get; set; }

        [Display(Name = "是否匿名")]
        public bool IsAnonymous { get; set; }

        [Display(Name = "是否需要登录")]
        public bool RequireLogin { get; set; }

        [Display(Name = "投票类型")]
        public VoteType Type { get; set; }

        [Range(1, 10, ErrorMessage = "每人最多投票数必须在1-10之间")]
        [Display(Name = "每人最多投票数")]
        public int MaxVotesPerUser { get; set; }

        [Display(Name = "结果可见性")]
        public ResultVisibility ResultVisibility { get; set; }

        [StringLength(50, ErrorMessage = "密码长度不能超过50个字符")]
        [Display(Name = "访问密码")]
        public string? Password { get; set; }

        [Display(Name = "允许修改投票")]
        public bool AllowModify { get; set; }

        [Display(Name = "结束后显示结果")]
        public bool ShowResultsAfterEnd { get; set; }

        [Display(Name = "选项")]
        public List<VoteOptionEditViewModel> Options { get; set; } = new List<VoteOptionEditViewModel>();
    }

    public class VoteOptionEditViewModel
    {
        public int Id { get; set; }

        [Required(ErrorMessage = "请输入选项标题")]
        [StringLength(100, ErrorMessage = "选项标题长度不能超过100个字符")]
        [Display(Name = "选项标题")]
        public string Title { get; set; } = string.Empty;

        [StringLength(500, ErrorMessage = "选项描述长度不能超过500个字符")]
        [Display(Name = "选项描述")]
        public string? Description { get; set; }

        [Display(Name = "选项图片")]
        public string? ImageUrl { get; set; }
    }
} 